/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Beans;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Thiago
 */
@Entity
@Table(name = "parcela", catalog = "trust", schema = "")
/*
@NamedQueries({
    @NamedQuery(name = "Parcela.findAll", query = "SELECT p FROM Parcela p"),
    @NamedQuery(name = "Parcela.findByIdparcela", query = "SELECT p FROM Parcela p WHERE p.idparcela = :idparcela"),
    @NamedQuery(name = "Parcela.findByNumeroParcela", query = "SELECT p FROM Parcela p WHERE p.numeroParcela = :numeroParcela"),
    @NamedQuery(name = "Parcela.findByValorParcela", query = "SELECT p FROM Parcela p WHERE p.valorParcela = :valorParcela"),
    @NamedQuery(name = "Parcela.findByVencimentoParcela", query = "SELECT p FROM Parcela p WHERE p.vencimentoParcela = :vencimentoParcela"),
    @NamedQuery(name = "Parcela.findByDataPgtoParcela", query = "SELECT p FROM Parcela p WHERE p.dataPgtoParcela = :dataPgtoParcela"),
    @NamedQuery(name = "Parcela.findByValorPgtoParcela", query = "SELECT p FROM Parcela p WHERE p.valorPgtoParcela = :valorPgtoParcela"),
    @NamedQuery(name = "Parcela.findBySaldoParcela", query = "SELECT p FROM Parcela p WHERE p.saldoParcela = :saldoParcela"),
    @NamedQuery(name = "Parcela.findByStatusParcela", query = "SELECT p FROM Parcela p WHERE p.statusParcela = :statusParcela"),
    @NamedQuery(name = "Parcela.findByIdCompra", query = "SELECT p FROM Parcela p WHERE p.idCompra = :idCompra")})
*/
public class Parcela implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idparcela")
    private Integer idparcela;
    @Basic(optional = false)
    @Column(name = "numeroParcela")
    private int numeroParcela;
    @Basic(optional = false)
    @Column(name = "valorParcela")
    private double valorParcela;
    @Basic(optional = false)
    @Column(name = "vencimentoParcela")
    @Temporal(TemporalType.DATE)
    private Date vencimentoParcela;
    @Column(name = "dataPgtoParcela")
    @Temporal(TemporalType.DATE)
    private Date dataPgtoParcela;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "valorPgtoParcela")
    private Double valorPgtoParcela;
    @Column(name = "saldoParcela")
    private Double saldoParcela;
    @Column(name = "statusParcela")
    private String statusParcela;
    
    @ManyToOne
    @JoinColumn(name = "idCompra")
    private Compra compra;

    public Parcela() {
    }

    public Parcela(Integer idparcela) {
        this.idparcela = idparcela;
    }

    public Parcela(Integer idparcela, int numeroParcela, double valorParcela, Date vencimentoParcela, Compra compra) {
        this.idparcela = idparcela;
        this.numeroParcela = numeroParcela;
        this.valorParcela = valorParcela;
        this.vencimentoParcela = vencimentoParcela;
        this.compra = compra;
    }

    public Integer getIdparcela() {
        return idparcela;
    }

    public void setIdparcela(Integer idparcela) {
        Integer oldIdparcela = this.idparcela;
        this.idparcela = idparcela;
        changeSupport.firePropertyChange("idparcela", oldIdparcela, idparcela);
    }

    public int getNumeroParcela() {
        return numeroParcela;
    }

    public void setNumeroParcela(int numeroParcela) {
        int oldNumeroParcela = this.numeroParcela;
        this.numeroParcela = numeroParcela;
        changeSupport.firePropertyChange("numeroParcela", oldNumeroParcela, numeroParcela);
    }

    public double getValorParcela() {
        return valorParcela;
    }

    public void setValorParcela(double valorParcela) {
        double oldValorParcela = this.valorParcela;
        this.valorParcela = valorParcela;
        changeSupport.firePropertyChange("valorParcela", oldValorParcela, valorParcela);
    }

    public Date getVencimentoParcela() {
        return vencimentoParcela;
    }

    public void setVencimentoParcela(Date vencimentoParcela) {
        Date oldVencimentoParcela = this.vencimentoParcela;
        this.vencimentoParcela = vencimentoParcela;
        changeSupport.firePropertyChange("vencimentoParcela", oldVencimentoParcela, vencimentoParcela);
    }

    public Date getDataPgtoParcela() {
        return dataPgtoParcela;
    }

    public void setDataPgtoParcela(Date dataPgtoParcela) {
        Date oldDataPgtoParcela = this.dataPgtoParcela;
        this.dataPgtoParcela = dataPgtoParcela;
        changeSupport.firePropertyChange("dataPgtoParcela", oldDataPgtoParcela, dataPgtoParcela);
    }

    public Double getValorPgtoParcela() {
        return valorPgtoParcela;
    }

    public void setValorPgtoParcela(Double valorPgtoParcela) {
        Double oldValorPgtoParcela = this.valorPgtoParcela;
        this.valorPgtoParcela = valorPgtoParcela;
        changeSupport.firePropertyChange("valorPgtoParcela", oldValorPgtoParcela, valorPgtoParcela);
    }

    public Double getSaldoParcela() {
        return saldoParcela;
    }

    public void setSaldoParcela(Double saldoParcela) {
        Double oldSaldoParcela = this.saldoParcela;
        this.saldoParcela = saldoParcela;
        changeSupport.firePropertyChange("saldoParcela", oldSaldoParcela, saldoParcela);
    }

    public String getStatusParcela() {
        return statusParcela;
    }

    public void setStatusParcela(String statusParcela) {
        String oldStatusParcela = this.statusParcela;
        this.statusParcela = statusParcela;
        changeSupport.firePropertyChange("statusParcela", oldStatusParcela, statusParcela);
    }

    public Compra getCompra() {
        return compra;
    }

    public void setCompra(Compra compra) {
        Compra oldCompra = this.compra;
        this.compra = compra;
        changeSupport.firePropertyChange("compra", oldCompra, compra);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idparcela != null ? idparcela.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Parcela)) {
            return false;
        }
        Parcela other = (Parcela) object;
        if ((this.idparcela == null && other.idparcela != null) || (this.idparcela != null && !this.idparcela.equals(other.idparcela))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "View.Parcela[ idparcela=" + idparcela + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
